const mongoose = require('mongoose');
/**
 * @typedef {Object} Menu
 * @description 菜单模型
 * @property {string} key - 菜单Key
 * @property {string} title - 菜单名称
 * @property {string} path - 路由路径
 * @property {string} icon - 图标
 * @property {string} parentId - 父菜单ID
 * @property {number} sort - 排序
 * @property {string} remark - 备注
 * @property {boolean} status - 状态
 * @property {string[]} children - 子菜单数组

 */


const menuSchema = new mongoose.Schema({
  key: String,         // 菜单Key
  title: String,       // 菜单名称
  path: String,        // 路由路径
  icon: String,        // 图标
  parentId: String,    // 父菜单ID
  sort: Number,       // 排序
  remark: String,      // 备注
  status: Boolean,     // 状态
  children: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Menu' }],  // 子菜单
});

const Menu = mongoose.model('Menu', menuSchema);

module.exports = Menu;
